<%--
  User: ssl
  Date: 2018-5-14
  Time: 15:16
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/WEB-INF/views/commons/taglibs.jsp" %>
<!-- 导入公用js -->
<%@ include file="/WEB-INF/views/commons/headjs.jsp" %>
<form id="updateForm" action="" method="post">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title" id="myModalLabel">修改资源</h4>
    </div>
    <div class="modal-body">
        <div class="row">
            <input type="hidden" name="id" value="${menu.id}">
            <div class="form-group">
                <label>资源名称：</label>
                <input type="text" name="name" value="${menu.name}" placeholder="例如：资源管理,用户管理,···" class="form-control">
            </div>
            <div class="form-group">
                <label>资源类型：</label>
                <input type="text" name="type" value="${menu.type}" placeholder="例如：menu,button···"
                       class="form-control">
            </div>
            <div class="form-group">
                <label>资源链接：</label>
                <input type="text" name="href" value="${menu.href}" placeholder="例如：/menu/list,/index···"
                       class="form-control">
            </div>
            <div class="form-group">
                <label>资源图标：</label>
                <input type="text" name="icon" value="${menu.icon}" placeholder="例如：fa-bar-chart-o,···"
                       class="form-control">
            </div>
            <div class="form-group">
                <label>权限标识：</label>
                <input type="text" name="permission" value="${menu.permission}" placeholder="例如：menu,meun:create,···"
                       class="form-control">
            </div>
            <div class="form-group">
                <label>资源排序：</label>
                <input type="text" name="sort" value="${menu.sort}" placeholder="例如：1,2,3,···" class="form-control">
            </div>
        </div>
    </div>
    <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
        <button type="submit" class="btn btn-primary">提交更改</button>
    </div>
</form>
<%@ include file="/WEB-INF/views/commons/foot.jsp" %>
<script>
    $(function () {
        $("#updateForm").validate({
            rules: {
                name: {
                    required: true
                },
                type: {
                    required: true
                },
                permission: {
                    required: true
                },
                sort: {
                    required: true
                }
            },
            submitHandler: function () {
                var url = "${ctx}/sys/menu/update";
                var postData = $("#updateForm").serialize();
                var result = rmsAjax(url, false, "POST", postData);
                if (!!result) {
                    if ("1" == result.code) {
                        notify("成功", "修改成功", "success");
                        window.location.href = "${ctx}/sys/menu";
                    } else {
                        notify("错误", result.msg, "error");
                    }
                } else {
                    return;
                }
            }
        });
    })

</script>